package ConcurrentProgramming;

import sun.awt.windows.ThemeReader;

@SuppressWarnings("all")
public class DemoLiftOff2 extends Thread{
    protected int countDown = 10;
    private static int taskCount = 0;
    private final int id = taskCount+1;
    public DemoLiftOff2() {

    }
    public DemoLiftOff2(int countDown) {
        this.countDown = countDown;
    }
    public String status() {
        return "#" + id + "(" + ((countDown > 0) ? countDown : "LiftOff!") + ")";
    }

    @Override
    public void run() {
        while (countDown-- > 0) {
            System.out.println(status());
            try {
                Thread.sleep(1000);
                Thread.yield();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        DemoLiftOff2 demoLiftOff2 = new DemoLiftOff2(10);
        demoLiftOff2.start(); // 启动线程 底层调用的是run方法
    }
}
